package com.sxds.wn.model;

import java.io.Serializable;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import com.sxds.wn.util.ReflectUtil;

/**
 * Description: <p>基础对象继承类</p>
 * Content Desc:<p>
 * <p>
 *  持久化基类，采用java.lang.ref包的内省机制覆盖父类的toString()、equals(Object o)、hasCode()方法<br/>
 *  hibernate持久层调用的方法
 * </p>
 *<p>
 * Copy Right of Personal Tangtao 2007-2020
 * @author Andy
 * @version 1.0
 */
public abstract class BaseObject implements Serializable {
	
    /**
     * 覆盖父类的toString()
     * @return POJO子类详细信息
     */
    public String toString() {
        return ToStringBuilder.reflectionToString(this,ToStringStyle.MULTI_LINE_STYLE);
    }

    /**
     * 覆盖父类的equals(Object o)方法
     */
    public boolean equals(Object o) {
        return EqualsBuilder.reflectionEquals(this, o);
    }
    
    /**
     * 覆盖父类的hasCode()方法
     */
    public int hashCode() {
    	return HashCodeBuilder.reflectionHashCode(this);
    }
    
    /**
     * 将此对象转发为Javascript object对象,产生的脚本代码如下
     * 如下:{propertyName:propertyName(array),propertyName1:propertyValue2....}
     * @return
     */
    public String toJavascript() throws Exception{
    	return ReflectUtil.toJavascript(this);
    }
   
}
